package cn.dgut.training.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class GroupBuyingRulesVO<T>  {

    @ApiModelProperty(value = "团购规则表的ID")
    private Long id;

    @ApiModelProperty(value = "商品id")
    private Long goodsId;

    @ApiModelProperty(value = "商品名称")
    private String goodsName;

    @ApiModelProperty(value = "商品图片或者商品货品图片")
    private String picUrl;

    @ApiModelProperty(value = "优惠金额")
    private BigDecimal discount;

    @ApiModelProperty(value = "达到优惠条件的人数")
    private Integer discountMember;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "团购过期时间")
    private Date expireTime;

    @ApiModelProperty(value = "团购规则状态，正常上线则0，到期自动下线则1，管理手动下线则2")
    private Integer status;

    @ApiModelProperty(value = "货品id")
    private long productId;

    @ApiModelProperty(value = "商品规格值列表，采用JSON数组格式")
    private String specifications;

    @ApiModelProperty(value = "商品货品数量")
    private Integer productNumber;

    /**
     * 总记录数
     */
    private Integer total;

    /**
     * 总页数
     */
    private Integer pages;
    /**
     * 每页条数
     */
    private Integer size;
    /**
     * 当前页
     */
    private Integer current;

    /**
     * 返回集合
     */
    List<T> list;

    public GroupBuyingRulesVO(IPage page) {

        this.total = ((Long)page.getTotal()).intValue();
        this.pages = ((Long)page.getPages()).intValue();
        this.size = ((Long)page.getSize()).intValue();
        this.current = ((Long)page.getCurrent()).intValue();
        this.list = page.getRecords();
    }
}
